{block content}
<div id="block_bg">
	<div id="block_left">
		<h1 class="block">
				<span n:if="$task->project"><a n:href="Project:overview $task[project_id]" style="color: white;">{$task->project[name]}</a>: </span>{$task[name]}
				<div class="settings" style="float: right;"><a href="javascript:void(0)" class="menuTrigger"  data-id="{$task[id]}" data-status="{$task[task_status_id]}" data-completed="{$task[completed]}" data-creator="{= (int)($user->id == $task[creator_id])}" data-worker="{= (int)($user->id == $task[worker_id])}"><img class="menuImage" src="{$basePath}/images/action.png" ></a></div>
		</h1>
		<div id="task_info" class="block">
			<table id="task_overview">
				<tr>
					<td>
						<table>
							<tr><td>Realizátor:</td><td>{$task->worker[name]} {$task->worker[surname]}</td></tr>
							<tr><td>Priorita:</td><td>{$task->task_priority[name]}</td></tr>
							<tr><td>Stav:</td><td>{$task->task_status[name]}</td></tr>
						</table>
					</td>
					<td>
						<table>
							<tr><td>Začátek:</td><td>{$task[start]|date:"j.n.Y"}</td></tr>
							<tr><td>Deadline:</td><td>{$task[deadline]|date:"j.n.Y"}</td></tr>
							<tr><td>Zadal:</td><td>{$task->creator[name]} {$task->creator[surname]}</td></tr>
						</table>
					</td>
				</tr>
			</table>
		</div>
		<div></div>
		{if $task[description] != ''}
		<div class="block">
			<h2>Popis</h2>
			<div class="left_block_bg">{!$task[description]|texy}</div>
		</div>
		{/if}

		{if count($prerequisites) > 0}
		<div class="block">
			<h2>Prerekvizity</h2>
			<div class="left_block_bg">
		{foreach $prerequisites as $prerequisite}
				<div><a href="{link task, $prerequisite->prerequisite[id]}">{$prerequisite->prerequisite[name]}</a> - {$prerequisite->prerequisite[completed]}% ({$prerequisite->prerequisite->task_status[name]})</div>
		{/foreach}
			</div>
		</div>
		{/if}

		{if count($preconditionFor) > 0}
		<div class="block">
			<h2>Podmiňující pro</h2>
			<div class="left_block_bg">
		{foreach $preconditionFor as $precondition}
				<div><a href="{link task, $precondition->task[id]}">{$precondition->task[name]}</a> - {$precondition->task[completed]}% ({$precondition->task->task_status[name]})</div>
		{/foreach}
			</div>
		</div>
		{/if}

		{if count($history) > 0}
		<div class="block">
			<h2>Historie</h2>
			<div class="left_block_bg">
		{foreach $history as $record}
				<div>{$record[date]|date:"j.n.Y H:i"} -
		{if $record['type'] == 'status'}Změněn stav na <em>{$record->task_status[name]}</em>{var $lastStatus = $record->task_status['name']}{/if}
		{if $record['type'] == 'completed'}Změněno dokončení na <em>{$record[completed]}%</em>{/if}
					({$record->user[name]} {$record->user[surname]})
				</div>
		{/foreach}
			</div>
		</div>
		{/if}

		<div class="block">
			<h2>Komentáře</h2>
			<div class="left_block_bg">
				{foreach $comments as $comment}
				<div class="comment{last} last{/last}">
					<div class="from"><strong>{$comment->user[name]} {$comment->user[surname]}</strong> napsal(a):</div>
					<div class="when">{$comment[date]|date:"j.n.Y H:i"}</div>
					<div class="clear"></div>
					<div class="text">{$comment[text]}</div>
				</div>
				{/foreach}
				{if $user->isAllowed('comment','add') || $user->isAllowed('comment','edit') || $user->isAllowed($projectResource,'comment_add') || $user->isAllowed($projectResource,'comment_edit')}
				{if count($comments) > 0}
				<hr>
				{/if}
				{form commentForm}
				<div class="center">
				{input text style=>'width:661px'}
				{input save}
				</div>
				{/form}
				{/if}
			</div>
		</div>
	</div>
	<div id="block_right">
		<div id="task_status" class="block">
			<h2>Dokončeno</h2>
			<div class="completed_graph"><div class="completed_bar" style="width: {$task[completed]}%"></div><div class="completed_text">{$task[completed]}%</div></div>
		</div>
		<div id="task_files" class="block">
			<h2>Soubory</h2>
			{foreach $task->task_file() as $file}
			{first}<table><tr><th>Název</th><th>Vložil</th><th></th></tr>{/first}
				<tr n:class="$file[description] == '' ? sep">
					<td><a n:href="downloadFile, $file[id]">{$file[name]}</a></td>
					<td>{$file->user[name]} {$file->user[surname]}</td>
					<td>
						<a n:href="deleteFile!, $file[id]" n:if="$user->isAllowed('files','edit') || $user->isAllowed($projectResource,'task_edit')" onclick="return del();"><img src="{$basePath}/images/delete.gif" alt="D" alt="Smazat"></a>
					</td>
				</tr>
				<tr n:if="$file[description] !== ''" class="sep"><td colspan="3"><em>{$file[description]}</em></td></tr>
			{last}</table>{/last}
			{/foreach}
			<div class="right"><a href="javascript:void(0)" id="show_upload">Přidat soubor</a></div>
			<div id="upload_form">
			{control uploadForm}
			</div>
		</div>
	</div>
	<div class="clear"></div>
</div>
{include #contextMenu, 'menuItemCssClass'=>'.menuTrigger'}
<script type="text/javascript">
$(function(){
	$("#upload_form").hide();
	$("#show_upload").click(function(){
		$("#upload_form").slideToggle();
		return false;
	});
});

function del(){ return confirm("Opravdu chcete soubor smazat?"); }

</script>
{/block}
{block head}
<link rel="stylesheet" href="{$basePath}/css/{$colorstyle}/task.css">
{/block}